package com.jl.jlapp.imageloader;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Shader;

import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;

import java.security.MessageDigest;

public class GlideRoundTransform
        extends BitmapTransformation {
    private float radius = 0.0F;

    public GlideRoundTransform(Context paramContext) {
        this(paramContext, 8.0F);
    }

    public GlideRoundTransform(Context paramContext, float paramFloat) {
        super();
        this.radius = (Resources.getSystem().getDisplayMetrics().density * paramFloat);
    }

    private Bitmap roundCrop(BitmapPool pool, Bitmap source) {
        if (source == null) return null;

        Bitmap result = pool.get(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
        if (result == null) {
            result = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
        }

        Canvas canvas = new Canvas(result);
        Paint paint = new Paint();
        paint.setShader(new BitmapShader(source, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
        paint.setAntiAlias(true);
        RectF rectF = new RectF(0f, 0f, source.getWidth(), source.getHeight());
        canvas.drawRoundRect(rectF, radius, radius, paint);
        return result;

    }

    public String getId() {
        return getClass().getName();
    }

    protected Bitmap transform(BitmapPool paramBitmapPool, Bitmap paramBitmap, int paramInt1, int paramInt2) {
        return roundCrop(paramBitmapPool, paramBitmap);
    }

    public void updateDiskCacheKey(MessageDigest paramMessageDigest) {
    }
}


/* Location:              /Users/davidzhang/Documents/decompileApk/jlfood-dex2jar.jar!/com/jl/jlapp/imageloader/GlideRoundTransform.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */